def binary_to_int(binary_str):
    """将二进制字符串转换为整数"""
    return int(binary_str, 2)

def decrypt_char(encrypted_char, k):
    """解密单个字符"""
    encrypted_value = binary_to_int(encrypted_char)
    original_value = encrypted_value // k  # 假设加密时是乘以 k
    return chr(original_value)

def decrypt_message(encrypted_message, k, block_size=8):
    """解密整个消息"""
    decrypted_message = ''
    for i in range(0, len(encrypted_message), block_size):
        block = encrypted_message[i:i + block_size]
        decrypted_char = decrypt_char(block, k)
        decrypted_message += decrypted_char
    return decrypted_message

def main():
    # 示例加密后的二进制字符串
    encrypted_message = '010101000100100001000101001000000100100101010011001000000101001101001111010011010010000001000101010000010100000010011000100110001001110'

    # 加密时使用的常数 k
    k = 2

    # 解密消息
    decrypted_message = decrypt_message(encrypted_message, k)

    print("解密后的消息:", decrypted_message)

if __name__ == "__main__":
    main()
